import request from '@/service/request' // 我的请求器
import type {
  LoginResponse,
  LoginParams,
  BaseResponse,
  UserInfoResponse,
  QuertListResponse,
  QuertListParams,
  QuertListItem
} from '@/service/type' // 类型

// 登录接口
export const loginApi = (params: LoginParams) => request.post<LoginResponse>('/api/login', params)

// 注册接口
export const registApi = (params: LoginParams) => request.post<Omit<BaseResponse, 'values'>>('/api/register', params)

// 用户信息接口
export const getUserInfoApi = () => request.get<BaseResponse<UserInfoResponse>>('/api/user/info')

// 查询列表接口
export const queryListApi = (params: QuertListParams) => request.get<BaseResponse<QuertListResponse>>('api/userlist', { params })

// 删除接口
export const delUserApi = (id: string) => request.post<BaseResponse>('/api/user/delete', { id })

// 添加接口
export const createUserApi = (params: QuertListItem) => request.post<BaseResponse>('/api/user/create', params)

// 编辑接口
export const updateUserApi = (params: QuertListItem) => request.post<BaseResponse>('/api/user/update', params)

// 获取xlsx工作文件接口
export const getXLSXApi = (ids: string[]) => request.post('/api/export', { ids }, { responseType: 'blob' })
